<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    li {
      list-style: none;
    }

    .box {
      display: flex;
      flex-wrap: wrap;
      width: 560px;
      margin: 20px auto;
    }

    .box li {
      width: 100px;
      height: 100px;
      margin: 0 10px 10px 0;
    }

    .box li img {
      width: 100%;
      height: 100%;
      border: 2px solid #258DF2;
      border-radius: 10px 0 10px 0;
    }
  </style>
</head>

<body>



  <script>
    let num = +prompt('请选择1-20英雄个数')


    document.write(` <ul class="box">`)
    for (let i = 1; i <= num; i++) {
      if (num > 20) {
        alert('太多了')
        break
      }
      document.write(`
       <li> <img src="../../../images/第三单元《for循环》/${i}.webp" alt=""></li>
      `)
    }

    document.write(`</ul>`)
  </script>

</body>

</html>